<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>公告</title>
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<link rel="stylesheet" href="css/oksub.css">
</head>
<body>
	<div class="layui-col-md12">
		<div class="layui-card">
			<div class="layui-card-header" id="title" style="text-align: center;"></div>
			<div class="layui-card-body" id="content"></div>
			<div class="layui-card-body">
				<div>
					<form class="layui-form" lay-filter="form">
						<button type="button" lay-submit lay-filter="download" id="download" class="layui-btn layui-btn-radius layui-btn-primary layui-btn-xs" >
							<i class="layui-icon">&#xe601;</i>下载附件
						</button>
						<input hidden="hidden" id="file_name" name="file_name" > 
						<input hidden="hidden" id="attachment" name="attachment" >
					<span style="float: right;" id="sender" ></span>
					<div style="text-align: right;" id="send_time"></div>
					</form>
					<div style="text-align: left;"></div>
				</div>
			</div>
		</div>
	</div>

<!--js逻辑-->
<script src="lib/layui/layui.js"></script>
<script>
	layui.use(["element", "jquery","form","okLayer", "okUtils", "okMock"], function () {
		let table = layui.table;
		let form = layui.form;
		let laydate = layui.laydate;
		let okLayer = layui.okLayer;
		let okUtils = layui.okUtils;
		let okMock = layui.okMock;
		let $ = layui.jquery;

	    $.post("api/anno?op=annoShow",{"id":0},function (data) {
	    	console.log(data);
			$("#file_name").val(data.file_name);
			$("#attachment").val(data.attachment);
			
	        $("#title").empty();
	        var titleHtml = data.title;
	        $("#title").html(titleHtml);
	        
	        $("#content").empty();
	        var contentHtml = data.content;
	        $("#content").html(contentHtml);
	        
	        $("#sender").empty();
	        var senderHtml = data.sender;
	        $("#sender").html(senderHtml);
	        
	        $("#send_time").empty();
	        var send_timeHtml = data.send_time;
	        $("#send_time").html(send_timeHtml);
	        
	    });
	    
	    form.on('submit(download)', function(dataObj){
	    	console.log(dataObj.field)
	    	location.href = "api/download?url="+dataObj.field.attachment+"&fileName="+dataObj.field.file_name;
	    });
	
	})
</script>

</body>
</html>